import React, { Component } from 'react'
import { Icon, Button, Table, Switch, Form, Input, Modal } from 'antd'

const FormItem = Form.Item;

class AddAnswerInput extends Component {
  constructor(props) {
    super(props);
    this.handleSubmit = this.handleSubmit.bind(this)
     this.state = {
      visible: false,
      loading: false,
      termsId:this.props.termsId
    }
    this.showModal=this.showModal.bind(this)
    this.handleOk=this.handleOk.bind(this)
    this.handleCancel=this.handleCancel.bind(this)
  }
  handleSubmit(e) {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (err) {
        return;
      }
      this.props.addOneTerm();
      
    });
  }
  showModal() {
    this.setState({
      visible: true,
    });
  }
  handleOk() {
    this.setState({ loading: true });
    setTimeout(() => {
      this.setState({ loading: false, visible: false });
    }, 3000);
  }
  handleCancel() {
    this.setState({ visible: false });
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <div>
        <Form inline onSubmit={this.handleSubmit}>
          <FormItem wrapperCol={{ span: 24, offset: 0 }} className="question-add-input">
            {getFieldDecorator('question', {
              rules: [{ required: true, message: '一定要输入一个名称哦' }],
            })(
              <Input addonBefore={<Icon type="plus" />} placeholder="请输入一个问题" />
            )}
          </FormItem>
        
          <FormItem  wrapperCol={{ span: 46, offset: 2 }}>
            <Button type="primary" htmlType="submit" > 添加一个问题</Button>
          </FormItem>
        </Form>

      </div>

    );
  }
}


AddAnswerInput = Form.create()(AddAnswerInput)
export default AddAnswerInput
